<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>hello</title>
    <!-- 导入vue包 -->
    <script src="./lib/vue2.6.10.js"></script>
    <script src="./lib/vue-router.js"></script>
</head>
<body>
    <div id="app">
        <router-link to="/acc">Home</router-link>
        <router-view></router-view>
    </div>

    <template id="acc">
        <div>
            <h1>用户信息</h1>
            <router-link to="/acc/reg">用户注册</router-link>
            <router-link to="/acc/login">用户登录</router-link>
            <hr>
            <router-view></router-view>
        </div>
    </template>
    <script>

        const acc = {
            template: "#acc"
        };
        const login = {
            template: "<h3>登录</h3>"
        };
        const reg = {
            template: "<h3>注册</h3>"
        };

        const router = new VueRouter({
            routes: [
                {
                    path: '/acc',
                    component: acc,
                    children:[
                        {path: 'login', component: login},
                        {path: 'reg', component: reg},
                    ]
                }
            ]
        })

        // 创建一个vue实例
        var vm = new Vue({
            el:'#app', // 当前new的这个vue实例要控制的DOM
            data:{     // 所有的数据
            },
            router
        })

    </script>
</body>
</html>